<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload = function(){
	function daojishi(){//倒计时函数
		var nowtime = new Date();//创建当前时间
		var juesai = new Date(2014,06,14,04,0,0);//创建未来时间
		var diff = juesai.getTime() - nowtime.getTime();//计算两个时间的时间差

		var tian = parseInt(diff/(24*60*60*1000));//获得天
		// diff = diff - tian*(24*60*60*1000);
		diff = diff%(24*60*60*1000);//获得计算完天之后还剩余的毫秒数
		var xiaoshi = parseInt(diff/(60*60*1000));//获得小时
		diff = diff%(60*60*1000);//获得计算完小时之后还剩余的毫秒数

		var fen = parseInt(diff/(60*1000));//计算分钟
		diff  = diff%(60*1000);//获得计算完分钟还剩余的毫秒数
		
		var miao = parseInt(diff/1000);//计算秒

		// document.write('距离世界杯决赛还剩：'+tian+'天'+xiaoshi+'小时'+fen+'分钟'+miao+'秒');
		var title = document.getElementById('title');
		var spans = title.getElementsByTagName('span');//获得h1中的span标签、
		spans[0].innerHTML = tian;
		spans[1].innerHTML = xiaoshi;
		spans[2].innerHTML = fen;
		spans[3].innerHTML = miao;
	}
	daojishi();
	setInterval(daojishi,1000);//每隔一秒钟走一回倒计时函数
	
}
	


</script>
</head>

<body>

<h1 id="title">距离巴西世界杯决赛还剩：<span>0</span>天<span>0</span>小时<span>0</span>分<span>0</span>秒</h1>



</body>
</html>
